﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Model;
using Common;
using System.Xml;
using DevExpress.XtraTreeList;

namespace Controller
{
   public class CodeFactaryBO
    {

        private CodeFactaryDAO _CFDAO;
        public CodeFactaryDAO CFDAO
        {
            get 
            {
                if (_CFDAO == null)
                    _CFDAO = FactoryModelDAO.CurrentFA.CreateCodeFactaryDAOInstance();
                return _CFDAO; 
            }
        }

        public void SaveConfig(TreeList tl)
        {
            string path = String.Format("{0}{1}", PubConstant.ConfigPath, PubConstant.CodeShopName);
            XmlDocument doc = new XmlDocument();

            doc.Load(path);
            CFDAO.SaveConfig(doc,tl);
            doc.Save(path);
        }

        public void LoadConfig(TreeList tl)
        {
            string path = String.Format("{0}{1}", PubConstant.ConfigPath, PubConstant.CodeShopName);
            XmlDocument doc = new XmlDocument();
            doc.Load(path);
 
            CFDAO.LoadConfig(doc, tl);
        }
    }
}
